home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cdity
/
ModeProSrc.lha
/
Daemon
/
Unnamed1
/
40beta
/
MPReadArgs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-12
|
3KB
|
129 lines
#include <proto/dos.h>
#include "MP.h"
BOOL GetReadArgs(void);
BOOL RAYesNo(STRPTR Str, BOOL DefVal);
ULONG RAInt(ULONG *Val,ULONG DefVal);
STRPTR RAString(STRPTR Str, STRPTR DefVal);
BOOL GetToolTypes(int argc, char **argv);
struct RDArgs *RArgs;
UBYTE DefPrefsPath[]="sys:prefs/ModeProPrefs";
UBYTE RATemplate[]="CX_PRIORITY/N/K,CX_POPKEY/K,CX_POPUP/K,"
"NLM=NEWLOOKMENUS/S,"
"CPROG=CATCH_NEWPROGRAMS/S,CSCR=CATCH_NEWSCREENS/S,CPOP=CATCH_POPUP/S,"
"PCMD=PREFSCOMMAND/K";
LONG RAResults[10]={0};
#define CX_PRIORITY 0
#define CX_POPKEY 1
#define CX_POPUP 2
#define NLM 3
#define CPROG 4
#define CSCR 5
#define CPOP 6
#define PREFS 7
BOOL GetArgs(int argc, char **argv)
{
if(argc) //cli
return(GetReadArgs());
return(GetToolTypes(argc,argv));
}
void CleanupArgs(int argc)
{
if(argc)//cli
{
if(RArgs)
FreeArgs(RArgs);
}
else
ArgArrayDone();
}
extern struct MPSem MPSem;
extern UBYTE *Hotkey,Popup;
extern BYTE Priority;
extern STRPTR PrefsPath;
BOOL GetReadArgs(void)
{
if(RArgs=ReadArgs(RATemplate,RAResults,0))
{
Hotkey =RAString((STRPTR)RAResults[CX_POPKEY],Hotkey);
Popup =RAYesNo((STRPTR)RAResults[CX_POPUP],Popup);
Priority =RAInt ((ULONG *)RAResults[CX_PRIORITY],Priority);
MPSem.EnabledNLM =RAResults[NLM];
MPSem.CatchPrograms =RAResults[CPROG];
MPSem.CatchScreens =RAResults[CSCR];
MPSem.CatchPopup =RAResults[CPOP];
// UserFontName=RAResults[FNAME];
// UserFontSize=RAInt (RAResults[FSIZE],8);
PrefsPath =RAString((STRPTR)RAResults[PREFS],DefPrefsPath);
return(TRUE);
}
else
PrintFault(IoErr(),0);
return(FALSE);
}
BOOL RAYesNo(STRPTR Str, BOOL DefVal)
{
if(Str)
{
switch(*Str)
{
case 'T':
case 't':
case 'Y':
case 'y':
return(~0);
case 'F':
case 'f':
case 'N':
case 'n':
return(0);
}
}
return(DefVal);
}
ULONG RAInt(ULONG *Val,ULONG DefVal)
{
if(Val)
return(*Val);
return(DefVal);
}
STRPTR RAString(STRPTR Str, STRPTR DefVal)
{
if(Str)
return(Str);
return(DefVal);
}
BOOL GetToolTypes(int argc, char **argv)
{
UBYTE **ttypes;
ttypes =ArgArrayInit(argc,argv);
Hotkey =ArgString(ttypes,(UBYTE *)"CX_POPKEY",(UBYTE *)"lcommand p");
Priority=ArgInt (ttypes,(UBYTE *)"CX_PRIORITY",0);
Popup =ArgYesNo (ttypes,(UBYTE *)"CX_POPUP",TRUE);
MPSem.EnabledNLM=ArgYesNo(ttypes,(UBYTE *)"NEWLOOKMENUS",FALSE);
MPSem.CatchPrograms =ArgYesNo (ttypes,(UBYTE *)"CATCH_NEWPROGRAMS",FALSE);
MPSem.CatchScreens =ArgYesNo (ttypes,(UBYTE *)"CATCH_NEWSCREENS",FALSE);
MPSem.CatchPopup =ArgYesNo (ttypes,(UBYTE *)"CATCH_POPUP",FALSE);
//UserFontName=ArgString(ttypes,(UBYTE *)"FONT_NAME",0);
//UserFontSize=ArgInt (ttypes,(UBYTE *)"FONT_SIZE",8);
PrefsPath =ArgString (ttypes,(UBYTE *)"PREFSCOMMAND",DefPrefsPath);
return((BOOL)ttypes);
}